//
//  mainmenu.mm
//  iXorsPattern
//
//  Created by Dmitry Tatarinov on 1/30/15.
//  Copyright (c) 2015 Huly-Gun Soft. All rights reserved.
//

#import "mainmenu.h"
//#import "game.h"
#import "vars.h"

void MenuStage::Load()
{
    //cntrl = (ViewController*)controller;
    controller.gameCenterBtn.hidden = false;
    
	// load fonts
	_mainFont    = xLoadFont("mainfont");
	xSetFont(_mainFont);
    
	// set stage as active
	MakeActive();
}

void MenuStage::Update()
{
	for(int i = 0; i < xCountTouches(); i++)
	{
		if(xTouchPhase(i) > 0){
			x_t=xTouchX(i);
			y_t=xTouchY(i);
            NSLog(@"tap");
		}
		xFlushTouches();
	}
}

void MenuStage::Render()
{
	xCls();
	xRenderWorld(1.0);
	
	// draw text information
	char buff[256];
	sprintf(buff, "FPS: %i\nx: %i\ny: %i", xFPSCounter(),x_t,y_t);
	xText(5, 5, buff, false, false);
	
	// present scene
    xFlip();	
	
}

void MenuStage::Unload()
{
	xFreeFont(_mainFont);
	xFlushTouches();
}
